from pathlib import Path
import os
import json
BASE_DIR = Path(__file__).resolve().parent.parent

STATIC_FOLDER = os.path.join(BASE_DIR, 'static')
DATABASE={
    'mongodb':{
        'DATABASE':'pyproject',
        "HOST":'127.0.0.1',
        "PORT":27017
    }
}
CACHE = {
    'redis':{
        'DB':2,
        'HOST':'127.0.0.1',
        "PORT":6379
    }
}

TEMPLATES = {
    'DIRS':os.path.join(BASE_DIR, 'temp')
    # 'DIRS':'temps'
}
class Tool:
    @staticmethod
    def jsonStr(lists):
        return  json.dumps(lists,default=str, ensure_ascii=False, indent=2)
    @staticmethod
    def jsonApi(code=200,msg='成功',data=None):
        strObject={'code':code,'msg':msg,'data':data}
        return json.dumps(strObject,default=str, ensure_ascii=False, indent=2)